home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1994
/
MacHack 1994.toast
/
MacHack™94
/
Talks & Papers
/
Timothy Knox
/
yerk 3.66
/
Module source
/
Exam
< prev
next >
Wrap
Text File
|
1994-06-24
|
5KB
|
185 lines
\ exam - examine memory in a window
\ 12/20/84 cbd version 1
\ 9/17/86 cdn Ignore keystrokes while exam window active
\ 12/04/87 rfl Fixed up mistakes
\ 9/26/90 rfl now memory examined is only application's
\ 12/18/90 rfl initFont when bring window up
\ 2/28/92 rfl let it be dragged in grayrgn
\ 5/16/92 rfl modified for displaying larger memory address for virtual memory
Decimal
:Module examMod
Locked
// Ctl
Forget useWFont
// CtlWind
// vScroll
:CLASS scrollRect <super rect
var scrollRegion
( dh dv -- )
:M Scroll: pack abs: self swap get: scrollRegion call scrollrect ;M
:M New: 0 call NewRgn put: scrollRegion ;M
:M Kill: get: scrollRegion call disposeRgn 0 put: scrollRegion ;M
:M ptIn: word0 where: themouse pack abs: self call ptinrect i->l ;M
;CLASS
ctlWind exWind
vscroll exvs
control relBtn
radioID init: relBtn
control absBtn
radioID init: absBtn
control hereBtn
control addrBtn
control wordBtn
rect thePane
62 24 475 205 put: thePane
scrollRect scAddr
04 24 60 203 put: scAddr
scrollRect scRect
scRect =: thePane \ for scrolling
1 1 inset: scRect
0 value start
0 value xbase
0 value xcurs
16 constant nLines \ max lines for examine window
: maxMem $ 108 -base @ ;
\ ( addr -- ) set exVs,start to page starting at absolute addr
: >>page 0 +base max $ 130 -base @ 256 - min -> start start 256 / put: exvs ;
: exam alive: exWind
IF select: exWind
ELSE 29 40 529 280 put: tempRect
tempRect " Examine" 4 true true new: exWind
setLimits: exWind false setGrow: exWind
20 215 " Abs" exWind new: absBtn
80 215 " Rel" exWind new: relBtn
150 215 " Here" exWind new: hereBtn
245 215 " Address" exWind new: addrBtn
370 215 " Word" exWind new: wordBtn
getVrect: exWind 2drop 242 exWind new: exVs
0 +base 256 / $ 130 -base @ 256 / putRange: exVs here +base >>page
1 put: relBtn 0 put: absBtn
new: scAddr new: scRect initFont
THEN ;
: clrChr
@xy 2dup 11 - 2swap swap 18 + swap
put: temprect clear: temprect ;
: bcorrect get: relBtn IF -base THEN ;
\ draw numeric legend for the pane
: .Legend base hex curs -curs
1 tmode getTopX: thePane 1- getTopY: thePane 2- gotoxy
16 0
DO clrChr start bcorrect i+ $ 0F and 3 .r
LOOP @xy swap 14 + swap gotoxy 16 0
DO clrChr start bcorrect
i+ $ 0F and 0 <# # #> type
LOOP -> curs -> base ;
\ ( line# -- Yval ) goto xy for line#
: lineY 11 * getTopY: thePane + 11 + 4 swap gotoxy ;
: .addrs base hex curs -curs 16 0 DO i lineY
start i 16 * + bcorrect ( $ FFFFFF and 6) 9 .r cr LOOP -> curs -> base ;
\ ( addr -- ) dump a line of memory from absolute addr
: .line { addr \ hiAddr -- } base hex curs -curs
addr 16 + -> hiAddr
addr bcorrect 9 .R space
hiAddr addr
DO i -base c@ space 0 <# # # #> type
LOOP 2 spaces hiaddr addr
DO i -base c@ dup 32 < over 126 > or
IF drop 46
THEN emit
LOOP -> curs -> base ;
\ ( addr ) dump nlines of data from absolute addr for the examine window
: .page { addr -- }
nlines 0
DO i lineY addr i 16 * + .line
LOOP ;
\ draw the examine page
: drawPage
base -> xbase hex
curs -> xcurs -curs
clear: scRect clear: scAddr
draw: thePane
.legend 1 tmode start .page
xcurs -> curs
xbase -> base ;
\ ( yVal -- ) scroll by yval
: scrollPage { yval -- }
0 yVal scroll: scAddr
0 yval scroll: scRect ;
: doDn
-11 scrollPage 15 lineY
start 16 + $ 130 -base @ min >>page
start 240 + .line ;
: doUp
start
IF 11 scrollPage 0 lineY start 16 - 0 +base max >>page
start .line THEN ;
: +rel 0 put: absBtn 1 put: relBtn clear: scAddr .legend .addrs ;
: -rel 1 put: absBtn 0 put: relBtn clear: scAddr .legend .addrs ;
: >here here +base >>page update: exWind ;
\ get a new start address from input dialog and dump
: >addr
base -> xbase hex
" Dump from hex address:" doInDlg
IF here >str255 1+ here c@ >uc
BL here count + c!
here number drop get: relBtn
IF +base THEN >>page update: exWind
THEN
xbase -> base ;
\ get a word name from input dialog and dump it
: >word
" Dump from name:" doInDlg
IF sFind
IF drop nfa +base >>page update: exWind
THEN
THEN ;
: PgUp start 256 - >>page drawPage ;
: PgDn start 256 + >>page drawPage ;
\ : doThumb start 256 * put: exVs ;
: doThumb get: exVs 256 * -> start update: exWind ;
: closEx
kill: scRect kill: scAddr
'c exammod munlock ;
5 'cfas doup dodn Pgup Pgdn doThumb actions: exVs
4 'cfas closEx null drawPage null actions: exWind
'c +rel actions: relBtn
'c -rel actions: absBtn
'c >here actions: herebtn
'c >addr actions: addrBtn
'c >word actions: wordBtn
;Module